<template>
  <view>
    <view style="width: 92%;margin: 0 auto;">
      <view style="line-height: 100rpx;font-size: 30rpx;color: #333333;">{{xq.title || ''}}</view>
      <view style="overflow: hidden;" v-if="false">
        <RichText :nodes="content" />
      </view>
      <!-- {{ content }} -->
      <u-parse :content="content"></u-parse>
      <!-- <editor :content="content" /> -->
      <view v-if="xq.type==5">
        <view v-if="xq.is_check==2" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            @click="tongguo"
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #1fb0ac;color: #FFFFFF;font-size: 28rpx;margin-right: 20rpx;"
          >同意</view>
          <view
            @click="jujue"
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #DD524D;color: #FFFFFF;font-size: 28rpx;"
          >拒绝</view>
        </view>
        <view v-if="xq.is_check==1" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #eee;color: #000;font-size: 28rpx;margin-right: 20rpx;"
          >审核通过</view>
        </view>
        <view v-if="xq.is_check==-1" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #eee;color: #000;font-size: 28rpx;margin-right: 20rpx;"
          >审核已拒绝</view>
        </view>
      </view>
      <view v-if="xq.type==6">
        <view v-if="xq.is_check==2" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            @click="tongguo1"
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #1fb0ac;color: #FFFFFF;font-size: 28rpx;margin-right: 20rpx;"
          >同意</view>
          <view
            @click="jujue1"
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #DD524D;color: #FFFFFF;font-size: 28rpx;"
          >拒绝</view>
        </view>
        <view v-if="xq.is_check==1" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #eee;color: #000;font-size: 28rpx;margin-right: 20rpx;"
          >审核通过</view>
        </view>
        <view v-if="xq.is_check==-1" style="width: 100%;box-sizing: border-box;display: flex;padding-bottom: 30rpx;margin-top: 40rpx;">
          <view
            style="flex: 1;line-height: 80rpx;text-align: center;border-radius: 40rpx;background-color: #eee;color: #000;font-size: 28rpx;margin-right: 20rpx;"
          >审核已拒绝</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      id: '',
      xq: {},
      content: '',
      index: ''
    }
  },
  onLoad(option) {
    this.id = option.id
    // this.index=option.index
    this.xiang()
  },
  onPullDownRefresh() {
    this.xiang()

    setTimeout(function () {
      uni.stopPullDownRefresh();
    }, 1500);
  },
  // onShareAppMessage: function(e) {
  // 				// let title = '恭喜dog.东西获得成功'
  // 				let that=this
  // 				return {
  // 					title: this.xiang.title,
  // 					path:'/pages/my/wtxq?id='+that.id,
  // 					success:function(){
  // 						that.post('api/share/share','',true).then(res=>{
  // 							uni.showToast({
  // 								title: res.msg,
  // 								icon: "none",
  // 								duration: 1000
  // 							})
  // 						})
  // 					}
  // 				}
  // 			},
  methods: {
    xiang: function () {
      // if(this.index==1){
      // 	this.post('api/index/problem_info',{id:this.id},true).then(res=>{
      // 		console.log(res)
      // 		if(res.code==1){
      // 			this.xq=res.data
      // 			this.content=res.data.main_content.replace(/<img/gi,   '<img class="rich-img" ')
      // 			                                                  .replace(/<p/g, '<div')
      // 			                                                  .replace(/\/p>/g, '\div>');
      // 		}
      // 	})
      // }else if(this.index==2){
      this.post('api/chat/notice_info', { notice_id: this.id }, true).then(res => {
        console.log(res)
        if (res.code == 1) {
          this.xq = res.data
          this.content = res.data.main_content.replace(/<img/gi, '<img class="rich-img" ')
            .replace(/<p/g, '<div')
            .replace(/\/p>/g, '\div>');
        }
      })
      // }
    },

    tongguo: function () {
      let that = this
      uni.showModal({
        title: '提示',
        content: '您确定同意该邀请？',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            that.post('api/firm/join_company', { notice_id: that.id }, true).then(res => {
              console.log(res)
              if (res.code == 1) {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
                setTimeout(function () {
                  uni.switchTab({
                    url: '/pages/index/xiaoxi'
                  })
                }, 1500)
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });

    },
    jujue: function () {
      let that = this
      uni.showModal({
        title: '提示',
        content: '您确定拒绝该邀请？',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            that.post('api/firm/refuse_company', { notice_id: that.id }, true).then(res => {
              console.log(res)
              if (res.code == 1) {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
                setTimeout(function () {
                  uni.switchTab({
                    url: '/pages/index/xiaoxi'
                  })
                }, 1500)
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });

    },

    tongguo1: function () {
      let that = this
      uni.showModal({
        title: '提示',
        content: '您确定同意该申请？',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            that.post('api/firm/check_join_success', { client_id: that.xq.client_id, notice_id: that.id }, true).then(res => {
              console.log(res)
              if (res.code == 1) {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
                setTimeout(function () {
                  uni.switchTab({
                    url: '/pages/index/xiaoxi'
                  })
                }, 1500)
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });

    },
    jujue1: function () {
      let that = this
      uni.showModal({
        title: '提示',
        content: '您确定拒绝该申请？',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            that.post('api/firm/check_join_refuse', { client_id: that.xq.client_id, notice_id: that.id }, true).then(res => {
              console.log(res)
              if (res.code == 1) {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
                setTimeout(function () {
                  uni.switchTab({
                    url: '/pages/index/xiaoxi'
                  })
                }, 1500)
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: "none",
                  duration: 1000
                })
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });

    }

  }
}
</script>

<style lang="scss">
.rich-img {
  max-width: 100% !important;
  height: auto !important;
  // background-color: #FFFFFF;
}
page {
  background-color: #f5f5f5 !important;
  padding-top: 50rpx !important;
  font-family: Demibold;
}
</style>
